package readinglist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/")
public class ReadingListController {
    private ReadingListRepository readingListRepository;
    @Autowired
    public ReadingListController(ReadingListRepository readingListRepository) {
        this.readingListRepository = readingListRepository;
    }
//    @RequestMapping(value="/{reader}", method=RequestMethod.GET)
//    public String readersBooks(
//            @PathVariable("reader") String reader,
//            Model model) {
//        List<Book> readingList =
//                readingListRepository.findByReader(reader);
//        if (readingList != null) {
//            model.addAttribute("books", readingList);
//        }
//        return "readingList";
//    }
//    @RequestMapping(value="/{reader}", method=RequestMethod.POST)
//    public String addToReadingList(
//            @PathVariable("reader") String reader, Book book) {
//        book.setReader(reader);
//        readingListRepository.save(book);
//        return "redirect:/{reader}";
//    }
    @RequestMapping(value="/index", method=RequestMethod.GET)
    public ModelAndView index() {
        System.out.println("################");
        ModelAndView modelAndView = new ModelAndView("index");
        return modelAndView;
    }
//    @BusiResource(res_type = ResTypeEnum.API)
//    @RequestMapping(value="/ttt", method=RequestMethod.GET)
//    @ResponseBody
//    public String ttt() {
//        System.out.println("== ttt ==");
//        return "just-a-test";
//    }
//
//    @BusiResource(res_type = ResTypeEnum.VIEW , auth = false)
//    @RequestMapping(value="/login", method=RequestMethod.GET)
//    @ResponseBody
//    public String login(HttpServletRequest request){
//        request.getSession().setAttribute(IamCoreConstants.USER_ACCOUNT_SESSION_ATTR,"maojianfeng");
//        AuditMiscPart1 part1 = new AuditMiscPart1();
//        part1.setProid(ProductEnum.ProductEnumP1);
//        request.setAttribute(IamCoreConstants.AUDITMISCPART1_REQUSET_ATTR,part1);
//        return request.getSession().getAttribute(IamCoreConstants.USER_ACCOUNT_SESSION_ATTR).toString();
//    }
}
